using System;
using System.Collections.Generic;
using System.Text;
using CookComputing.XmlRpc;
using System.Net;

namespace NMollom.Internal {
    /// <summary>
    /// The parameter bag for requesting a captcha from Mollom.
    /// </summary>
    public class GetCaptchaParams : Params {
        [XmlRpcMember("session_id")]
        public string sessionId = "";
        [XmlRpcMember("author_ip")]
        public string authorIp = "";

        /// <summary>
        /// Creates a new CaptchaParams object.
        /// </summary>
        /// <param name="auth">The authentication to use.</param>
        /// <param name="previousAssesment">A previous assesment object if it exists. This will reuse the session id of the specified assesment. Can be null.</param>
        /// <param name="authorIp">The IP address of the author for which to display a captcha. Can be null.</param>
        public GetCaptchaParams(Authentication auth, ContentAssesment previousAssesment, IPAddress authorIp)
            : base(auth) {
            this.sessionId = previousAssesment == null ? "" : previousAssesment.SessionId;
            this.authorIp = authorIp == null ? "" : authorIp.ToString();
        }

        /// <summary>
        /// Creates a new CaptchaParams object.
        /// </summary>
        /// <param name="auth">The authentication to use.</param>
        /// <param name="previousCaptcha">A previous captcha result object if it exists. This will reuse the session id of the specified assesment. Can be null.</param>
        /// <param name="authorIp">The IP address of the author for which to display a captcha. Can be null.</param>
        public GetCaptchaParams(Authentication auth, Captcha previousCaptcha, IPAddress authorIp)
            : base(auth) {
            this.sessionId = previousCaptcha == null ? "" : previousCaptcha.SessionId;
            this.authorIp = authorIp == null ? "" : authorIp.ToString();
        }
    }
}
